<?php
/**
 * Registration request object
 * 
 * @package stanza.iq.register
 */
class Zend_Jabber_Stanza_Request_Iq_Register_Set extends Zend_Jabber_Stanza_Request_Iq_Register_Abstract {
    /**
     * Create registration object
     * 
     * @param Zend_Jabber_User $user New user
     * @param string $password User password
     * @param array Other fields needed when registering new user
     */
    public function __construct(Zend_Jabber_User $user, $password, $otherFields = array()) {
        parent::__construct();
        
        $query = $this->dom->createElement('query');
        $query->setAttribute('xmlns', $this->getNamespace());
        
        $username = $this->dom->createElement('username', $user->getUsername());
        $query->appendChild($username);
        
        $password = $this->dom->createElement('password', $password);
        $query->appendChild($password);
        
        foreach($otherFields as $fieldName => $fieldValue) {
            $field = $this->dom->createElement($fieldName, $fieldValue);
            $query->appendChild($field);
        }
        
        $this->iqNode->appendChild($query);
    }
}
?>